package http

import (
	"net"
	"net/http"
	"time"
)

var client *http.Client

// Client http client
func Client() *http.Client {
	if client == nil {
		client = &http.Client{Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
			DialContext: (&net.Dialer{
				Timeout:   30 * time.Second,
				KeepAlive: 30 * time.Second,
			}).DialContext,
			MaxIdleConns:        1000,
			DisableKeepAlives:   true,
			MaxIdleConnsPerHost: 1000,
			IdleConnTimeout:     30 * time.Second,
		}}
	}
	return client
}

